#include "scheduler.h"

typedef struct {
	void (*task_func)(void);
	uint32_t run_rate;
	uint32_t last_run_time;
}task;

static task task_num[]={
	{led_proc,1,0},
	{key_proc,10,0},
	{LCD_proc,50,0},
	{tim_ic_proc,99,0}

};


uint8_t task_number;
void scheduler_init(void)
{
	
	task_number =   sizeof(task_num)/sizeof(task);
}

void scheduler_run(void)
{
	for(int i = 0;i<task_number;i++)
	{
		uint32_t now_time = HAL_GetTick();
		if(now_time >= task_num[i].run_rate + task_num[i].last_run_time)
		{
			task_num[i].task_func();
			task_num[i].last_run_time = now_time;
		}
	}
}